<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	
	
	
<a onClick="flgSubmitInfo()" >支付</a>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<a onClick="flgSubmitInfo2(32)" >未支付</a>	
	
<script type="text/javascript" src="{$_C.hy_path}js/jquery-1.10.2.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
 function flgSubmitInfo(){
	 
	 var url = "index.php?g=mobile&m=wxpay&a=beforehandPay";
		$.post(url,"",function(res){
			console.info(res);
			if(res.error=="1"){
			}else{
				wx.chooseWXPay({
				    package: res.result.package,
				    nonceStr: res.result.nonceStr, 
				    paySign: res.result.paySign,
				    signType: res.result.signType,
				    timestamp: res.result.timeStamp, 
				    success: function (resu) {
						if(resu.errMsg == "chooseWXPay:ok"){
							successPayOrderQuery(res.out_trade_no);
                        }

				    }
				});
			}
		},"json");
 }
 function successPayOrderQuery(out_trade_no){
 	 var url = "index.php?g=mobile&m=wxpay&a=orderquery&out_trade_no="+out_trade_no;
	$.get(url,function(res){
		if(res=="SUCCESS"){
			showMsg("下单成功");
		}else{
			showMsg("下单失败");
		}
	},"text");
 }
 function showMsg(msg){
 	alert(msg);
 }
 
 function flgSubmitInfo2(id){
 	 var url = "index.php?g=mobile&m=wxpay&a=chooseWXPay&wx_pay_id="+id;
	$.get(url,function(res){
			if(res.error=="1"){
				showMsg(res.content);
			}else{
				wx.chooseWXPay({
				    package: res.result.package,
				    nonceStr: res.result.nonceStr, 
				    paySign: res.result.paySign,
				    signType: res.result.signType,
				    timestamp: res.result.timeStamp, 
				    success: function (resu) {
						if(resu.errMsg == "chooseWXPay:ok"){
                           successPayOrderQuery(res.out_trade_no);
                        }

				    }
				});
			}
	},"json");
 }
 
 
 
 
				 var pid = "{$info.wxid|default:'0'}";
				  wx.config({
				    debug: false, 
				    appId: '{$signPackage.appId}',
				    timestamp: {$signPackage.timestamp},
				    nonceStr: '{$signPackage.nonceStr}',
				    signature: '{$signPackage.signature}',
				    jsApiList: [
				      // 所有要调用的 API 都要加到这个列表中
				      'chooseWXPay',
				      'onMenuShareAppMessage',
				    
				    ]
				  });
				
			  wx.ready(function () {
			  	
	
	  });
	</script>


</body>
</html>